<?php
    ob_start();
    header("content-type:text/html; charset=utf-8");
	session_start();
	header("Cache-control: private");
	$conn =@mysql_connect("localhost","root","123456","MYSQL_CLIENT_INTERACTIVE") or die("Please refresh the page");  
	@mysql_select_db("sql_sandib2bcn",$conn); 
	@mysql_query("set names utf-8");
?>

<?php
//url chuli
function urlstr($urlstr){
$urlstr=str_replace("&","",$urlstr);
$urlstr=str_replace(",","",$urlstr);
$urlstr=str_replace(" ","-",$urlstr);
$urlstr=str_replace("--","-",$urlstr);
$urlstr=str_replace(".","",$urlstr);
$urlstr=str_replace("#","",$urlstr);
$urlstr=str_replace(";","",$urlstr);
$urlstr=str_replace("/",",",$urlstr);
return $urlstr;
}
?>
<?php
// wen ben ru ku qian tai diao yong  chuli
function unhtml($fString){
$fString = str_replace(CHR(32)," ",$fString);
$fString = str_replace(CHR(13),"",$fString);
$fString = str_replace(CHR(10) & CHR(10),"</P><P>",$fString);
$fString = str_replace(CHR(10),"<BR><BR>",$fString);
return $fString;}
?>
<?php 
//jie qu zhong wen zi fu chuan
function mysubstr($str, $start, $len) {
    $tmpstr = "";
    $strlen = $start + $len;
    for($i = 0; $i < $strlen; $i++) {
        if(ord(substr($str, $i, 1)) > 0xa0) {
            $tmpstr .= substr($str, $i, 2);
            $i++;
        } else
            $tmpstr .= substr($str, $i, 1);
    }
    return $tmpstr;
}
// wen ben ru ku qian tai diao yong  chuli
function html_php($content){
        $content = htmlspecialchars($content);
        $content = str_replace("\n", "<br>", $content);
        $content = str_replace("  ", "&nbsp;&nbsp;", $content);
        $content = str_replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $content);
        return $content;
}
?>
<?php
function imgstr($img_url,$img_w,$img_h){
$img=getimagesize($img_url);
$w=$img[0];
$h=$img[1];
$a=$img_w/$w;
$b=$img_h/$h;
  if($a<1||$b<1){
     if($a>=$b){
        echo "width='";
        echo ($img_w>ceil($w*$b))?ceil($w*$b):$img_w;
        echo "' height='$img_h'";
     }else{
   
        echo "width='$img_w'";
        echo " height='";
		echo ($img_h>ceil($h*$b))?$h_img:$img_h;
		echo "'";
     }
  }else{
   echo "width='";
   echo $w;
   echo "' height='";
   echo $h;
   echo "'";
  }
}
?>